﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;

namespace DAL
{
    using DAL.Entities;

    public class PhieukhamtheotrangthaikhamDAL : BaseDAL, UTL.IBaseDAL 
    {
        public int Count()
        {
            throw new NotImplementedException();
        }

        public DataTable Select()
        {
            throw new NotImplementedException();
        }

        public DataTable Select(object obj)
        {
            throw new NotImplementedException();
        }

        public object GetByKey(object key)
        {
            throw new NotImplementedException();
        }

        public bool Delete(string id)
        {
            throw new NotImplementedException();
        }

        public bool Insert(object obj)
        {
            throw new NotImplementedException();
        }

        public bool Update(object obj)
        {
            throw new NotImplementedException();
        }

        public DataTable Search(string name)
        {
            throw new NotImplementedException();
        }
        public DataTable Phieukhamtheotrangthai(string id)

        {
            string sql = @"select a.STTPHIEU, a.NGAYKHAM, c.HOTEN_BN as HotenBN,(case when c.GIOITINH_BN = 1 then 'Nam' else N'Nữ' end) as GioitinhBN,d.TENPHONG,e.TENKHOA,b.TENTRANGTHAI
                        from PHIEUKHAM a join TRANGTHAIKHAM b on a.MATRANGTHAI= b.MATRANGTHAI
                        join BENHNHAN c on a.MA_BN=c.MA_BN join PHONG d on  a.SOPHONG = d.SOPHONG and a.MAKHOA =d.MAKHOA
                        join KHOA e on d.MAKHOA = e.MAKHOA
                        where b.MATRANGTHAI= '{0}'";
            sql = string.Format(sql, id);
            return ExecuteQuery(sql);
        }
        public DataTable select_trangthaikham()
        {
            string sql = @"select distinct a.matrangthai as id,tentrangthai as ten from trangthaikham a join phieukham b on a.matrangthai=b.matrangthai";
            return ExecuteQuery(sql);
        }
      
        /// <summary>
        /// lay ...
        /// </summary>
        /// <returns></returns>
     

        public bool deleteobj(object obj)
        {
            throw new NotImplementedException();
        }
    }
}
